package com.thinkmore.business.action;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 封装的action基类
 * 
 * @author lizhuang
 */
public class BaseController {
	protected static final Log otherLogger = LogFactory.getLog("other");
	@Autowired
	protected HttpServletRequest request;
	@Autowired
	protected HttpServletResponse response;

	protected Map<String, Object> paramsToCondition() {
		Map<String, Object> requestParamsMap = new HashMap<String, Object>();
		Enumeration<?> paramNames = request.getParameterNames();
		while (paramNames != null && paramNames.hasMoreElements()) {
			Object paramName = paramNames.nextElement();
			if (paramName != null) {
				Object paramValue = request.getParameterValues(paramName.toString());
				requestParamsMap.put(paramName.toString(), ((String[]) paramValue)[0]);
			}
		}
		return requestParamsMap;
	}
}
